home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: chang.unx.sas.com!walker
- From: walker@chang.unx.sas.com (Doug Walker)
- Subject: Re: C compiler problem
- Sender: news@unx.sas.com (Noter of Newsworthy Events)
- Message-ID: <DM5I1y.J46@unx.sas.com>
- Date: Fri, 2 Feb 1996 13:41:58 GMT
- X-Nntp-Posting-Host: chang.unx.sas.com
- References: <4ek3b2$a5k@nntp.novia.net> <3005pbd60.alamito@marketgraph.xs4all.nl> <4eqe9n$jsa@odin.diku.dk>
- Organization: SAS Institute Inc.
-
- In article <4eqe9n$jsa@odin.diku.dk>,
- Torsten Poulin Nielsen <torsten@diku.dk> wrote:
- >rvg@marketgraph.xs4all.nl (Ruud van Gaal) writes:
- >
- >>In <4ek3b2$a5k@nntp.novia.net> tsyslo@oasis.novia.net (Tony Syslo) wrote:
- >
- >>>int main()
- >
- >>void main(void) is better prototyped in C. C++ might use void main()
- >
- >Doesn't ANSI say int main()? At least void main break under some
- >compilers.
- >
-
- ANSI forbids the compiler to provide a prototype for main(), so either
- will compile. However, ANSI states that main() should be declared one
- of two ways:
-
- int main(int argc, char *argv[]);
-
- int main(void);
-
- (See 2.1.2.2 in the ANSI standard for C for details.)
-
- Under some implementations, declaring main as void will cause a trash
- return value to be sent to the system after the program exits, which
- in turn may cause the system to believe that the program has failed.
- This was a problem with SAS/C 6.50, but we fixed it in later versions
- by forcing the compiler to generate a 0 in register d0 upon the return
- of main() if it was declared void.
-
- (Arguably we should have let it fail, but previous versions of SAS/C did
- not have the failure behavior, so we judged it more important to
- preserve backward compatibility than to force the user to recognize
- his error.)
-
- --
- ***** / walker@unx.sas.com
- *|_o_o|\\ Doug Walker< BIX, Portal: djwalker
- *|. o.| || \ AOL: weissblau
- | o |//
- ======
- Any opinions expressed are mine, not those of SAS Institute, Inc.
-
-